<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% int validaSession = 3; %>
<%@ include file="Connections/session.jsp" %>
<%@ include file="Connections/conDB.jsp" %>
<%
	final String ARRL_UNIDADES	= "arrL_unidades";
	final String ID_ALMACEN 	= "id_almac";
	final String VOID		 	= "";
	java.util.ArrayList arrL_unidades = null;
	String mensaje = null;

	String str_almacenDestino 	= request.getParameter(ID_ALMACEN);
	str_almacenDestino 			= (str_almacenDestino == null || str_almacenDestino.equals(VOID)) ? "0" : str_almacenDestino;
	int int_almacenDestino 		= Integer.parseInt(str_almacenDestino);
	
	java.sql.Driver     DriverRs 	= (java.sql.Driver)Class.forName(MM_conDB_DRIVER).newInstance();
	java.sql.Connection ConnRs   	= java.sql.DriverManager.getConnection(MM_conDB_STRING,MM_conDB_USERNAME,MM_conDB_PASSWORD);
	java.sql.Driver     DriverRsInf = (java.sql.Driver)Class.forName(MM_conDBinf_DRIVER).newInstance();
	java.sql.Connection ConnRsInf 	= java.sql.DriverManager.getConnection(MM_conDBinf_STRING,MM_conDBinf_USERNAME,MM_conDBinf_PASSWORD);
	
	try{
		arrL_unidades = (java.util.ArrayList)session.getAttribute(ARRL_UNIDADES);
		
		if(ConnRs!=null && ConnRsInf!=null && arrL_unidades!=null && int_almacenDestino>0){
			arrL_unidades = KC.EntradaUnidad.guarda_entrada(ConnRs, ConnRsInf, int_almacenDestino , arrL_unidades);
		}else{
			mensaje = "Error de conexion";
		}
	}catch(Exception e){
		throw e;
	}finally{
		if(!ConnRs.isClosed()){ConnRs.close();}
		if(!ConnRsInf.isClosed()){ConnRsInf.close();}
	}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cimav2 ~ Insertar Recpci&oacute;n Unidades Excel</title>
</head>
<script type="text/javascript">
	window,alert('<%=mensaje %>');
	window.close();
</script>
<body>

</body>
</html>